package com.jblog.core.dao.blog.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.jblog.Constants;
import com.jblog.core.dao.base.EntityDao4Mybatis;
import com.jblog.core.dao.blog.PostDao;
import com.jblog.core.model.blog.Post;
import com.jblog.core.model.blog.param.PostParam;

@Repository
@SuppressWarnings("unchecked")
public class PostDaoImpl extends EntityDao4Mybatis<Post, Long> implements PostDao {

    @Override
    public Long getMaxId() {
        return Long.valueOf(super.getSqlSession().selectOne(
                getNamespace() + Constants.MyBatis.GET_MAX_ID).toString());
    }

    @Override
    public List<Post> getPrevious(PostParam p) {
        return super.getSqlSession().selectList(
                getNamespace() + Constants.MyBatis.GET_PREVIOUS, p);
    }

    @Override
    public List<Post> getNext(PostParam p) {
        return super.getSqlSession().selectList(
                getNamespace() + Constants.MyBatis.GET_NEXT, p);
    }

}
